package rlex.classes.program;

public class Procedure {
	private String name;
	private VariableDeclarationList parameters;
	private VariableDeclarationList vars;
	private ProcedureList subprocedure;
	private Command code;
	
	public VariableDeclarationList getParameters() {
		return parameters;
	}
	public void setParameters(VariableDeclarationList parameters) {
		this.parameters = parameters;
	}
	public VariableDeclarationList getVars() {
		return vars;
	}
	public void setVars(VariableDeclarationList vars) {
		this.vars = vars;
	}
	public ProcedureList getSubprocedure() {
		return subprocedure;
	}
	public void setSubprocedure(ProcedureList subprocedure) {
		this.subprocedure = subprocedure;
	}
	public Command getCode() {
		return code;
	}
	public void setCode(Command code) {
		this.code = code;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	public String toString() {
		String ret = "Procedure " + name + "(" + parameters.toString() + ") ";
		if (vars != null) {
			ret += "[" + vars.toString() + "] ";
		}
		if (subprocedure != null) {
			ret += "{" + subprocedure.toString() + "} ";
		}
		ret += code.toString();
		return ret;
	}
	
	public void display(int level) {
		System.out.print("Name: " + name + " : ");
		parameters.display(0);
		if (vars != null) {
			vars.display(0);
		} else {
			System.out.println("No VARS\n");
		}
		if (subprocedure != null) {
			subprocedure.display(0);
		} else {
			System.out.println("No SUBPROCEDURES\n");
		}
		System.out.println("Command:");
		code.display(0);
		System.out.println("\n");
	}
	
}
